<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane">
            <{if $bind_google_secret}>
            <h2>绑定验证码后方可安全正常使用后台</h2>
            <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"
                 style="padding: 20px ;">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="username" <{if isset($data)}>value="<{$data->username}>"
                        readonly <{/if}>
                        lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <{if isset($qrcodeurl)}>
                <div class="layui-form-item">
                    <label class="layui-form-label">绑验证码</label>
                    <div class="layui-input-block">
                        <input type="text" name="verifycode" value="" placeholder="扫码后产生的验证码" autocomplete="off"
                               class="layui-input"><br>
                        1. 用安装了google验证码软件的手机扫码如下二维码<br>
                        2. 在上面的输入框中输入产生的随机验证码<br>
                        <img src="<{$qrcodeurl}>"/>
                        <input type="hidden" name="google2fa_key" value="<{$google2fa_key}>">
                    </div>
                </div>
                <{/if}>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="button" class="layui-btn" lay-submit lay-filter="form-submit"
                               id="role-form-submit"
                               value="提交绑定"></div>
                </div>
            </div>
            <{else}>
            <div style="padding: 200px;font-size: 50px">
                <center>欢迎使用 <{$application_name}></center>
            </div>
            <{/if}>
        </form>

    </div>
</div>
<script type="text/javascript">
    layui.use(['form'], function () {
        var $ = layui.$
            , form = layui.form;
        //监听提交
        form.render();
        form.on('submit(form-submit)', function (data) {
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            //提交 Ajax 成功后，关闭当前弹层并重载表格
            //$.ajax({});
            $.post('/<{$module}>/<{$controller}>/<{$action}>?isajax=1', field, function (res) {
                if (res.code == 0) {
                    //ok
                    layer.msg(res.msg);
                    top.window.location = '/admin/login/out';
                } else {
                    layer.msg(res.msg);
                }
            }, 'json')
        });
    })
</script>